package me.sdevil507.systemAssist.systemUserWorkSapce.repository;

import me.sdevil507.systemAssist.systemUserWorkSapce.po.SystemUserWorkSpacePO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: tips_back_end
 * @description:
 * @author: kzl
 * @create: 2020-07-02 11:54
 **/
public interface SystemUserWorkSpaceRepository extends JpaRepository<SystemUserWorkSpacePO, Long>, JpaSpecificationExecutor<SystemUserWorkSpacePO>, QuerydslPredicateExecutor<SystemUserWorkSpacePO> {

    /**
     * 逻辑删除
     *
     * @param id 成果id
     */
    @Transactional(rollbackFor = Exception.class)
    @Modifying(clearAutomatically = true)
    @Query(value = "update SystemUserWorkSpacePO a set a.isDel=true where a.moduleId=:id and a.userId=:userId")
    void logicDelete(@Param("id") Long id, @Param("userId") Long userId);
}
